/*  This file is part of -_-.

    -_- is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    -_- is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with -_-.  If not, see <http://www.gnu.org/licenses/>.

    Copyright 2012 Oliver Katz */

#ifndef __VISUAL_DISPLAY_ENGINE_API_H
#define __VISUAL_DISPLAY_ENGINE_API_H

#include "display_engine.h"
#include <string.h>
#include <malloc.h>

#define Z_WIDGET_SIZE(name, widget, hint) sleepyface::visual::display_engine::DisplayBox *_widgetsize_cxx_##name(sleepyface::visual::layout_engine::Widget *widget, sleepyface::visual::display_engine::DisplayBox *hint)
#define Z_WIDGET_RENDER(name, widget, x, y, size) sleepyface::visual::display_engine::DisplayBox *_widgetrender_cxx_##name(sleepyface::visual::layout_engine::Widget *widget, int x, int y, sleepyface::visual::display_engine::DisplayBox *size)
#define Z_CONTAINER_SIZE(name, container, hint) sleepyface::visual::display_engine::DisplayBox *_containersize_cxx_##name(sleepyface::visual::layout_engine::Container *container, sleepyface::visual::display_engine::DisplayBox *hint)
#define Z_CONTAINER_HINT(name, container, size) sleepyface::visual::display_engine::DisplayBox *_containerhint_cxx_##name(sleepyface::visual::layout_engine::Container *container, sleepyface::visual::display_engine::DisplayBox *size)
#define Z_CONTAINER_RENDER(name, container, x, y, size) sleepyface::visual::display_engine::DisplayBox *_containerrender_cxx_##name(sleepyface::visual::layout_engine::Container *container, int x, int y, sleepyface::visual::display_engine::DisplayBox *size)

#define Z_BEGIN_LINKAGE() extern "C" {
#define Z_END_LINKAGE() }
#define Z_LINK_WIDGET(name) sleepyface::visual::display_engine::DisplayBox *_widgetsize_##name(sleepyface::visual::layout_engine::Widget *w, sleepyface::visual::display_engine::DisplayBox *h) {return _widgetsize_cxx_##name(w, h);} sleepyface::visual::display_engine::DisplayBox *_widgetrender_##name(sleepyface::visual::layout_engine::Widget *w, int x, int y, sleepyface::visual::display_engine::DisplayBox *s) {return _widgetrender_cxx_##name(w, x, y, s);}
#define Z_LINK_CONTAINER(name) sleepyface::visual::display_engine::DisplayBox *_containersize_##name(sleepyface::visual::layout_engine::Container *c, sleepyface::visual::display_engine::DisplayBox *h) {return _containersize_cxx_##name(c, h);} DisplayBox *_containerhint_##name(sleepyface::visual::layout_engine::Container *c, sleepyface::visual::display_engine::DisplayBox *s) {return _containerhint_cxx_##name(c, s);} sleepyface::visual::display_engine::DisplayBox *_containerrender_##name(sleepyface::visual::layout_engine::Container *c, int x, int y, sleepyface::visual::display_engine::DisplayBox *s) {return _containerrender_cxx_##name(c, x, y, s);}

#define Z_BEGIN_LINKAGE_WIDGET_LIST() char **_list_widgets() {char *rtn[] = {
#define Z_END_LINKAGE_WIDGET_LIST() NULL}; char **buf = (char **)malloc(sizeof(rtn)); memcpy(buf, rtn, sizeof(rtn)); return buf;}
#define Z_BEGIN_LINKAGE_CONTAINER_LIST() char **_list_containers() {char *rtn[] = {
#define Z_END_LINKAGE_CONTAINER_LIST() Z_END_LINKAGE_WIDGET_LIST()
#define Z_LIST(name) (char *)#name,

#define Z_RETURN_HINTS(hints) return _return_hints(hints)

namespace sleepyface
{
    namespace visual
    {
        namespace display_engine
        {
            DisplayBox *_return_hints(vector<pair<DisplayBox, DisplayBox> > hints);

            DisplayBox *z_box_minimum(DisplayBox *db, int x, int y);
            DisplayBox *z_box_maximum(DisplayBox *db, int x, int y);
        }
    }
}

#endif